package cn.ixiaoxin.deepchat.mapper;

import cn.ixiaoxin.deepchat.VO.FriendsVO;
import cn.ixiaoxin.deepchat.entity.Friend;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface FriendMapper extends BaseMapper<Friend> {

    @Select("select f.*,u.* from (select user_id,friend_id,remark,status from friend where user_id = #{userId} and status = 1) f left join \n" +
            "(select id,username,nickname,avatar,phone,email,gender,birthday,signature,status as state from user where deleted = 0) u\n" +
            "on f.friend_id = u.id")
    List<FriendsVO> getFriends(@Param("userId") Long userId);
}
